gtk4.git
5 years agoa11y: Add testing API
Emmanuele Bassi [Fri, 17 Jul 2020 13:39:56 +0000 (14:39 +0100)]
a11y: Add testing API

We want to test the accessibility API, as well as the implementation
inside each widget. For that, we should expose an API that lets us
verify that a GtkAccessible has a given role, as well as a given
property.

The API follows the pattern of other GTest API:

 - a macro to assert that a condition is respected
 - a function that prints out the error message in case of failure

5 years agoa11y: Implement role and state change in GtkSwitch
Emmanuele Bassi [Fri, 17 Jul 2020 13:31:02 +0000 (14:31 +0100)]
a11y: Implement role and state change in GtkSwitch

Set the "switch" role, and update the "checked" state when the :active
property is toggled.

5 years agoa11y: Consolidate the attributes container
Emmanuele Bassi [Fri, 17 Jul 2020 11:49:59 +0000 (12:49 +0100)]
a11y: Consolidate the attributes container

While we have split the various attributes for convenience, there's no
reason why we should have specialised data types for the attributes
container object.

5 years agoa11y: Add relations API
Emmanuele Bassi [Fri, 17 Jul 2020 11:00:31 +0000 (12:00 +0100)]
a11y: Add relations API

Since we split relation attributes from the generic properties, we need
to add API for setting and retrieving their values.

5 years agoa11y: Simplify GtkAccessibleValue
Emmanuele Bassi [Thu, 16 Jul 2020 17:08:22 +0000 (18:08 +0100)]
a11y: Simplify GtkAccessibleValue

Reduce the amount of subclassing, by handling collection of fundamental
types directly from the generic code paths. We now handle boolean,
tristate, integer, number, string, and relation values in the generic
code path; if an attribute supports the "undefined" value, we return the
undefined value singleton.

5 years agoa11y: Resync with the ARIA spec
Emmanuele Bassi [Wed, 15 Jul 2020 18:08:37 +0000 (19:08 +0100)]
a11y: Resync with the ARIA spec

Drop roles and properties that were deprecated in WAI-ARIA 1.1, and add
new roles and properties defined in WAI-ARIA 1.2 and later.

We also split the relationship properties into their own enumeration, so
we can keep the GtkAccessibleProperty type more compact.

5 years agoRemove GTK_ACCESSIBLE_STATE_NONE
Emmanuele Bassi [Wed, 15 Jul 2020 12:20:38 +0000 (13:20 +0100)]
Remove GTK_ACCESSIBLE_STATE_NONE

It's pointless, we can use an explicit value of `-1` everywhere.
Additionally, it complicates all code that uses the state enumeration as
an array index, since now we need to guard against a negative offset.

5 years agoa11y: Add binding-friendly accessible property setter
Emmanuele Bassi [Mon, 13 Jul 2020 16:47:36 +0000 (17:47 +0100)]
a11y: Add binding-friendly accessible property setter

Matching the one for the accessible state.

5 years agoa11y: Collect reference value
Emmanuele Bassi [Mon, 13 Jul 2020 16:43:06 +0000 (17:43 +0100)]
a11y: Collect reference value

Some properties that take a reference to an accessible haven't been
updated to collect the correct type.

5 years agoa11y: Update the accessible label for GtkButton
Emmanuele Bassi [Mon, 13 Jul 2020 16:04:38 +0000 (17:04 +0100)]
a11y: Update the accessible label for GtkButton

5 years agoa11y: Update GtkSeparator
Emmanuele Bassi [Mon, 13 Jul 2020 15:26:24 +0000 (16:26 +0100)]
a11y: Update GtkSeparator

Add an accessible role, and update the orientation state.

5 years agoa11y: Set the role for GtkScale
Emmanuele Bassi [Mon, 13 Jul 2020 15:22:44 +0000 (16:22 +0100)]
a11y: Set the role for GtkScale

5 years agoa11y: Update the accessible state for GtkRange
Emmanuele Bassi [Mon, 13 Jul 2020 15:22:22 +0000 (16:22 +0100)]
a11y: Update the accessible state for GtkRange

5 years agoa11y: Update the "pressed" state on toggle buttons
Emmanuele Bassi [Mon, 13 Jul 2020 15:10:36 +0000 (16:10 +0100)]
a11y: Update the "pressed" state on toggle buttons

5 years agoa11y: Add roles to various widgets
Emmanuele Bassi [Mon, 13 Jul 2020 15:03:27 +0000 (16:03 +0100)]
a11y: Add roles to various widgets

5 years agoAdd accessible properties to GtkAccessible
Emmanuele Bassi [Mon, 13 Jul 2020 14:51:39 +0000 (15:51 +0100)]
Add accessible properties to GtkAccessible

We propagate the accessible state and properties to each ATContext in
the same virtual function, since they are functionally similar.

5 years agoAdd GtkAccessiblePropertySet
Emmanuele Bassi [Sun, 12 Jul 2020 19:07:57 +0000 (20:07 +0100)]
Add GtkAccessiblePropertySet

Like GtkAccessibleStateSet, the PropertySet is a set for accessible
properties.

5 years agoPlumb all the GtkAccessibleProperty values into GtkAccessibleValue
Emmanuele Bassi [Mon, 13 Jul 2020 14:22:24 +0000 (15:22 +0100)]
Plumb all the GtkAccessibleProperty values into GtkAccessibleValue

Similarly to how we deal with GtkAccessibleState.

5 years agoAllow setting the accessible role at construction
Emmanuele Bassi [Mon, 13 Jul 2020 14:20:19 +0000 (15:20 +0100)]
Allow setting the accessible role at construction

Some widgets have different accessible roles depending on some
parameter, so we cannot set the role at class init time. For those
widgets, we add an "accessible-role" property to GtkAccessible, and we
allow setting it (only) at construction time.

5 years agoStart documenting the Accessibility API
Emmanuele Bassi [Wed, 8 Jul 2020 13:42:32 +0000 (14:42 +0100)]
Start documenting the Accessibility API

Add the introductory text from #2833, and the various types to the API
reference.

5 years agoUpdate the accessible state on widget visibility changes
Emmanuele Bassi [Tue, 7 Jul 2020 16:51:01 +0000 (17:51 +0100)]
Update the accessible state on widget visibility changes

The GTK_ACCESSIBLE_STATE_HIDDEN has the opposite meaning of the
GtkWidget:visible property.

5 years agoHave GtkWidget implement GtkAccessible
Emmanuele Bassi [Wed, 8 Jul 2020 15:58:11 +0000 (16:58 +0100)]
Have GtkWidget implement GtkAccessible

Each widget type has an accessible role associated to its class, as
roles cannot change during the life time of a widget instance.

Each widget is also responsible for creating an ATContext, to proxy
state changes to the underlying accessibility infrastructure.

5 years agoPlug GtkATContext into GtkAccessible
Emmanuele Bassi [Wed, 8 Jul 2020 15:56:31 +0000 (16:56 +0100)]
Plug GtkATContext into GtkAccessible

An Accessible implementation must create an ATContext object. UI
elements are supposed to interact with the GtkAccessible API, but we
expose GtkATContext to allow patterns like delegation.

5 years agoAdd GtkATContext
Emmanuele Bassi [Wed, 8 Jul 2020 15:51:57 +0000 (16:51 +0100)]
Add GtkATContext

The ATContext type is meant to be used as the base class for
implementations of the assistive technology API—the actual mechanism
needed to communicate to components like the screen reader, or any other
AT.

Every time the widget state changes, the ATContext is meant to broadcast
the state change; and every time the AT queries the state of a UI
element, the ATContext is meant to provide that information.

We also have a "test" ATContext implementation, which is meant to be
used to write tests to verify that changes are propagated without
requiring a whole desktop session.

5 years agoAdd GtkAccessibleStateSet
Emmanuele Bassi [Wed, 8 Jul 2020 15:45:57 +0000 (16:45 +0100)]
Add GtkAccessibleStateSet

Since states can be set or unset, we need a container type that has all
the possible states, and a bitmask that tells us which ones are set.

5 years agoAdd GtkAccessibleValue
Emmanuele Bassi [Wed, 8 Jul 2020 15:34:32 +0000 (16:34 +0100)]
Add GtkAccessibleValue

All accessible properties and states may have one of the following
types:

 - true/false
 - true/false/undefined
 - true/false/mixed/undefined
 - reference (to another UI element)
 - reference list
 - integer
 - number (real numerical value)
 - string
 - token (one of a limited set of allowed values)
 - token list

See: https://www.w3.org/WAI/PF/aria/states_and_properties#propcharacteristic_value

The GtkAccessibleValue is a simple reference counted type that can be
"subclassed" to implement each value type.

This initial commit adds GtkAccessibleValue and the basic subclasses for
plain boolean, tristate (true/false/undefined), and token types,
including statically allocated values that can be shared instead of
allocated.

5 years agoIntroduce GtkAccessible
Emmanuele Bassi [Tue, 16 Jun 2020 16:40:14 +0000 (17:40 +0100)]
Introduce GtkAccessible

GtkAccessible is an interface for accessible UI elements.

Currently, it doesn't do much except exist as a type; in the future, it
will be the entry point for all accessible state in GTK.

5 years agoa11y: Add the supported accessibility roles
Emmanuele Bassi [Tue, 16 Jun 2020 16:04:05 +0000 (17:04 +0100)]
a11y: Add the supported accessibility roles

The list of roles is taken from the WAI-ARIA 1.2 specification:

  https://w3c.github.io/aria/

Some of these roles do not make entirely sense from a GTK application
perspective, but we can remove them before finalizing the API.

5 years agoRemove ATK
Emmanuele Bassi [Tue, 16 Jun 2020 15:41:59 +0000 (16:41 +0100)]
Remove ATK

To build a better world sometimes means having to tear the old one down.
        -- Alexander Pierce, "Captain America: The Winter Soldier"

ATK served us well for nearly 20 years, but the world has changed, and
GTK has changed with it. Now ATK is mostly a hindrance towards improving
the accessibility stack:

 - it maps to a very specific implementation, AT-SPI, which is Linux and
   Unix specific
 - it requires implementing the same functionality in three different
   layers of the stack: AT-SPI, ATK, and GTK
 - only GTK uses it; every other Linux and Unix toolkit and application
   talks to AT-SPI directly, including assistive technologies

Sadly, we cannot incrementally port GTK to a new accessibility stack;
since ATK insulates us entirely from the underlying implementation, we
cannot replace it piecemeal. Instead, we're going to remove everything
and then incrementally build on a clean slate:

 - add an "accessible" interface, implemented by GTK objects directly,
   which describe the accessible role and state changes for every UI
   element
 - add an "assistive technology context" to proxy a native accessibility
   API, and assign it to every widget
 - implement the AT context depending on the platform

For more information, see: https://gitlab.gnome.org/GNOME/gtk/-/issues/2833

5 years agoMerge branch 'wip/otte/boolfilter' into 'master'
Benjamin Otte [Sun, 26 Jul 2020 19:24:25 +0000 (19:24 +0000)]
Merge branch 'wip/otte/boolfilter' into 'master'

Add GtkBoolFilter

See merge request GNOME/gtk!2288

5 years agoUpdate Catalan translation
Jordi Mas [Sun, 26 Jul 2020 19:13:16 +0000 (21:13 +0200)]
Update Catalan translation

5 years agoAdd GtkBoolFilter
Benjamin Otte [Sun, 26 Jul 2020 15:55:54 +0000 (17:55 +0200)]
Add GtkBoolFilter

Takes a boolean GtkExpression (like a boolean object property) to run a
filter with.

5 years agoMerge branch 'matthiasc/for-master' into 'master'
Matthias Clasen [Sun, 26 Jul 2020 12:00:49 +0000 (12:00 +0000)]
Merge branch 'matthiasc/for-master' into 'master'

overlaylayout: Document minimally

See merge request GNOME/gtk!2285

5 years agooverlaylayout: Document minimally
Matthias Clasen [Sat, 25 Jul 2020 23:02:33 +0000 (19:02 -0400)]
overlaylayout: Document minimally

This layout manager is not reusable, but we
still need to make its layout properties show
up in the docs.

5 years agoMerge branch 'matthiasc/for-master' into 'master'
Matthias Clasen [Sat, 25 Jul 2020 17:30:11 +0000 (17:30 +0000)]
Merge branch 'matthiasc/for-master' into 'master'

Matthiasc/for master

See merge request GNOME/gtk!2284

5 years agogtk: Improve struct packing in places
Matthias Clasen [Sat, 25 Jul 2020 02:57:34 +0000 (22:57 -0400)]
gtk: Improve struct packing in places

Plug some holes in our structs by rearranging
a few fields. This is was done looking at
pahole output.

5 years agogdk: Improve struct packing in places
Matthias Clasen [Sat, 25 Jul 2020 02:57:00 +0000 (22:57 -0400)]
gdk: Improve struct packing in places

Plug some holes in our structs by rearranging
a few fields. This is was done looking at
pahole output.

5 years agocolorswatch: Remove unused radius fields
Matthias Clasen [Sat, 25 Jul 2020 04:31:08 +0000 (00:31 -0400)]
colorswatch: Remove unused radius fields

The radius fields are never used.

5 years agohsla: Just store floats
Matthias Clasen [Sat, 25 Jul 2020 04:29:42 +0000 (00:29 -0400)]
hsla: Just store floats

We are using floats for rgb, and we don't need more precision
for hsl colors either. We use hsl for computing color expressions
like shade(), lighter() and darker(), which are not precisely
specified anyway.

This commit updates the one test where the output changes a
tiny bit due to this.

5 years agoheaderbar: Drop the Private struct
Matthias Clasen [Sat, 25 Jul 2020 11:40:24 +0000 (07:40 -0400)]
headerbar: Drop the Private struct

5 years agocolorplane: Drop the Private struct and padding
Matthias Clasen [Sat, 25 Jul 2020 02:56:24 +0000 (22:56 -0400)]
colorplane: Drop the Private struct and padding

5 years agoMerge branch 'matthiasc/for-master' into 'master'
Matthias Clasen [Sat, 25 Jul 2020 00:05:28 +0000 (00:05 +0000)]
Merge branch 'matthiasc/for-master' into 'master'

Matthiasc/for master

See merge request GNOME/gtk!2283

5 years agoMerge branch 'wip/otte/types' into 'master'
Matthias Clasen [Fri, 24 Jul 2020 23:54:01 +0000 (23:54 +0000)]
Merge branch 'wip/otte/types' into 'master'

Get rid of unneeded glib types

See merge request GNOME/gtk!2282

5 years agoAdd another sortlistmodel test
Matthias Clasen [Fri, 24 Jul 2020 23:28:21 +0000 (19:28 -0400)]
Add another sortlistmodel test

This tests the crash fix in f7b73b2e010960975.

5 years agotestsuite: Add an incremental sort test
Matthias Clasen [Fri, 24 Jul 2020 22:32:01 +0000 (18:32 -0400)]
testsuite: Add an incremental sort test

Add a test that makes changes to a model while it
is incrementally sorted.

5 years agotimsort: Avoid a crash
Matthias Clasen [Fri, 24 Jul 2020 23:22:12 +0000 (19:22 -0400)]
timsort: Avoid a crash

We need to clear the pointer after freeing the data,
since the sortlistmodel keeps its timsort structure
around and reuses it.

5 years agoReplace "gdouble" with "double"
Benjamin Otte [Fri, 24 Jul 2020 20:32:16 +0000 (22:32 +0200)]
Replace "gdouble" with "double"

5 years agoReplace "gfloat" with "float"
Benjamin Otte [Fri, 24 Jul 2020 20:25:56 +0000 (22:25 +0200)]
Replace "gfloat" with "float"

5 years agoReplace "gchar" with "char"
Benjamin Otte [Fri, 24 Jul 2020 18:40:36 +0000 (20:40 +0200)]
Replace "gchar" with "char"

5 years agoReplace "gint" with "int"
Benjamin Otte [Fri, 24 Jul 2020 13:54:49 +0000 (15:54 +0200)]
Replace "gint" with "int"

5 years agotestsuite: Use better names for sortlistmodel tests
Matthias Clasen [Fri, 24 Jul 2020 19:37:49 +0000 (15:37 -0400)]
testsuite: Use better names for sortlistmodel tests

Name the tests for what they do.

5 years agotestsuite: Reenable tests for incremental sort
Matthias Clasen [Fri, 24 Jul 2020 19:22:14 +0000 (15:22 -0400)]
testsuite: Reenable tests for incremental sort

This was unintentionally disabled.

5 years agoMerge branch 'remove-align-widget' into 'master'
Matthias Clasen [Fri, 24 Jul 2020 18:17:30 +0000 (18:17 +0000)]
Merge branch 'remove-align-widget' into 'master'

menubutton: Remove align-widget property

See merge request GNOME/gtk!2280

5 years agosortlistmodel: Fix a crash
Matthias Clasen [Fri, 24 Jul 2020 14:40:55 +0000 (10:40 -0400)]
sortlistmodel: Fix a crash

5 years agodropdown: Fix popup sizing
Matthias Clasen [Fri, 24 Jul 2020 13:07:45 +0000 (09:07 -0400)]
dropdown: Fix popup sizing

Setting a width request is not quite enough, since
gtk_widget_set_size_request() only queues a resize
when the widget is visible. Explicitly force one
here. Without this, the popup sometimes shows up
too small.

5 years agomenubutton: Remove align-widget property
Florian Müllner [Fri, 24 Jul 2020 11:39:38 +0000 (13:39 +0200)]
menubutton: Remove align-widget property

The property has been unused since commit 8701e34f749. That was four
years ago, so it's safe to say that nobody has been missing it terribly.

5 years agoMerge branch 'fix-gdk-array-msvc' into 'master'
Timm Bäder [Fri, 24 Jul 2020 09:28:21 +0000 (09:28 +0000)]
Merge branch 'fix-gdk-array-msvc' into 'master'

gdk/gdkarrayimpl.c: Fix build on Visual Studio

See merge request GNOME/gtk!2279

5 years agogdk/gdkarrayimpl.c: Fix build on Visual Studio
Chun-wei Fan [Fri, 24 Jul 2020 08:25:24 +0000 (16:25 +0800)]
gdk/gdkarrayimpl.c: Fix build on Visual Studio

It seems like initializing something to an empty array using `{}` is a GCCism,
so just stuff a 0 within the braces to accomplish the same thing.

5 years agoMerge branch 'matthiasc/for-master' into 'master'
Matthias Clasen [Fri, 24 Jul 2020 02:58:51 +0000 (02:58 +0000)]
Merge branch 'matthiasc/for-master' into 'master'

filechooser: Remove a leftover signal emission

Closes #2942

See merge request GNOME/gtk!2276

5 years agodocs: Work around escaping bugs
Matthias Clasen [Thu, 23 Jul 2020 20:14:33 +0000 (16:14 -0400)]
docs: Work around escaping bugs

This is truly a russian doll of documentation formats:
a string containing <> inside an xml fragment in an |[ ]|
gtk-doc example in markdown in a doc comment.

Sadly, something gets escaping wrong, so the <> end up
literally in the docbook and mess up the last step of
our document formatting, even after turning them into
entities.

Work around this with an extra level of entities that
really shouldn't be necessary.

5 years agodocs: Pass --standalone to pandoc
Matthias Clasen [Thu, 23 Jul 2020 19:46:06 +0000 (15:46 -0400)]
docs: Pass --standalone to pandoc

This flag causes pandoc to emit a proper doctype
declaration and, crucially, namespace declarations
for the xlink namespace that it insists on using
for href attributes. Without this, putting external
links in md documents doesn't survive the journey
through xml.

5 years agodocs: Improve shortcut trigger docs
Matthias Clasen [Thu, 23 Jul 2020 16:57:08 +0000 (12:57 -0400)]
docs: Improve shortcut trigger docs

Point out the need to escape <> in xml.

5 years agodocs: Explain the shortcutcontroller example a bit
Matthias Clasen [Thu, 23 Jul 2020 16:43:46 +0000 (12:43 -0400)]
docs: Explain the shortcutcontroller example a bit

Add a reference to the the syntax for shortcut actions
in builder files.

5 years agofilechooser: Remove a leftover signal emission
Matthias Clasen [Thu, 23 Jul 2020 11:58:57 +0000 (07:58 -0400)]
filechooser: Remove a leftover signal emission

Commit 0145809a94667c75ed4a4 replace the response-requested
signal with an action, but didn't actually remove the emission
of that no-longer-existing signal.

Fixes: #2942
5 years agoMerge branch 'wip/otte/for-master' into 'master'
Benjamin Otte [Thu, 23 Jul 2020 14:34:33 +0000 (14:34 +0000)]
Merge branch 'wip/otte/for-master' into 'master'

Wip/otte/for master

See merge request GNOME/gtk!2277

5 years agosearchenginemodel: Remove unused code
Benjamin Otte [Thu, 23 Jul 2020 01:35:26 +0000 (03:35 +0200)]
searchenginemodel: Remove unused code

5 years agosearchengine: Remove unused set_recursive() call
Benjamin Otte [Thu, 23 Jul 2020 01:06:42 +0000 (03:06 +0200)]
searchengine: Remove unused set_recursive() call

5 years agoUpdate Romanian translation
Florentina Mușat [Thu, 23 Jul 2020 10:33:16 +0000 (10:33 +0000)]
Update Romanian translation

5 years agoUpdate Romanian translation
Florentina Mușat [Thu, 23 Jul 2020 10:32:08 +0000 (10:32 +0000)]
Update Romanian translation

5 years agoMerge branch 'matthiasc/for-master' into 'master'
Matthias Clasen [Thu, 23 Jul 2020 00:19:15 +0000 (00:19 +0000)]
Merge branch 'matthiasc/for-master' into 'master'

Matthiasc/for master

See merge request GNOME/gtk!2275

5 years agoNEWS: Updates
Matthias Clasen [Wed, 22 Jul 2020 23:51:27 +0000 (19:51 -0400)]
NEWS: Updates

5 years agomigration guide: Add some tables
Matthias Clasen [Wed, 22 Jul 2020 23:38:58 +0000 (19:38 -0400)]
migration guide: Add some tables

Add a table mapping event signals to their event controller
replacements, and a table mapping former GtkContainer
subclasses to their gtk_container_add replacement.

5 years agoMerge branch 'wip/otte/for-master' into 'master'
Benjamin Otte [Wed, 22 Jul 2020 18:08:24 +0000 (18:08 +0000)]
Merge branch 'wip/otte/for-master' into 'master'

timsort: Actually 0-terminate the array in get_runs()

See merge request GNOME/gtk!2274

5 years agotimsort: Actually 0-terminate the array in get_runs()
Benjamin Otte [Wed, 22 Jul 2020 16:59:22 +0000 (18:59 +0200)]
timsort: Actually 0-terminate the array in get_runs()

This could cause SEGVs when changing the sort during an ongoing sort
operation.

5 years agoUpdate Ukrainian translation
Yuri Chornoivan [Wed, 22 Jul 2020 13:27:26 +0000 (13:27 +0000)]
Update Ukrainian translation

5 years agoUpdate Ukrainian translation
Yuri Chornoivan [Wed, 22 Jul 2020 13:22:09 +0000 (13:22 +0000)]
Update Ukrainian translation

5 years agoMerge branch 'wip/otte/sortlistmodel2' into 'master'
Matthias Clasen [Wed, 22 Jul 2020 13:15:45 +0000 (13:15 +0000)]
Merge branch 'wip/otte/sortlistmodel2' into 'master'

Massively refactor and improve sortlistmodel

See merge request GNOME/gtk!2273

5 years agoUpdate POTFILES.in
Piotr Drąg [Wed, 22 Jul 2020 13:01:05 +0000 (15:01 +0200)]
Update POTFILES.in

5 years agogtk-demo: Add a progress bar when the colors demo resorts
Benjamin Otte [Wed, 22 Jul 2020 01:18:33 +0000 (03:18 +0200)]
gtk-demo: Add a progress bar when the colors demo resorts

5 years agosortlistmodel: Add progress estimation
Benjamin Otte [Wed, 22 Jul 2020 00:50:58 +0000 (02:50 +0200)]
sortlistmodel: Add progress estimation

5 years agotimsort: Add progress estimation
Benjamin Otte [Sun, 12 Jul 2020 15:57:03 +0000 (17:57 +0200)]
timsort: Add progress estimation

5 years agosortlistmodel: Make key generation part of the step function
Benjamin Otte [Tue, 21 Jul 2020 23:43:59 +0000 (01:43 +0200)]
sortlistmodel: Make key generation part of the step function

SSave the missing keys as a bitset and iterate over that bitset in the
step function.

Solves the problem with a large UI block at the beginning of a sort
operation when all the keys were generated, in particular when key
generation was slow.

Benchmarks for maximum time taken by a single main loop callback:

     initial sort with complex GFileInfo keys
                       old      new
      32,000 items   137ms      3ms
     128,000 items   520ms     31ms

     initial sort with string keys
                       old      new
      32,000 items   187ms      1ms
     128,000 items   804ms      3ms

5 years agogtk-demo: Make colors demo do incremental sorting
Benjamin Otte [Tue, 21 Jul 2020 23:43:40 +0000 (01:43 +0200)]
gtk-demo: Make colors demo do incremental sorting

5 years agosortlistmodel: Properly compute runs
Benjamin Otte [Tue, 21 Jul 2020 02:50:05 +0000 (04:50 +0200)]
sortlistmodel: Properly compute runs

When updating a (partially) sorted model, take the known runs for the
existing sort and apply them to the new sort. That way, we don't have to
check the whole model again.

Benchmarks:

      appending half the items to a model of strings
                        old      new
      512,000 items   437ms    389ms
    1,024,000 items  1006ms    914ms

      appending 10% of the items to a model of strings
                        old      new
      512,000 items   206ms    132ms
    1,024,000 items   438ms    301ms

      appending 1 item to a model of strings
                        old      new
       64,000 items   1.8ms   0.00ms
      512,000 items     ---   0.01ms

5 years agosortlistmodel: Make sort stable again
Benjamin Otte [Tue, 21 Jul 2020 02:06:13 +0000 (04:06 +0200)]
sortlistmodel: Make sort stable again

Previously, the sort was not stable when items were added/removed while
sorting or the sort algorithm was changed.

Now the sort looks at the item position (via the key's location in the
keys array) to make sure each comparison stays stable with respect to
this position.

5 years agomultisorter: Implement GtkSortKeys
Benjamin Otte [Mon, 20 Jul 2020 20:24:36 +0000 (22:24 +0200)]
multisorter: Implement GtkSortKeys

5 years agotreelistrowsorter: Implement GtkSortKeys
Benjamin Otte [Sun, 19 Jul 2020 02:58:06 +0000 (04:58 +0200)]
treelistrowsorter: Implement GtkSortKeys

5 years agonumericsorter: Implement GtkSortKeys
Benjamin Otte [Thu, 16 Jul 2020 12:03:09 +0000 (14:03 +0200)]
numericsorter: Implement GtkSortKeys

5 years agostringsorter: Implement GtkSortKeys
Benjamin Otte [Wed, 15 Jul 2020 18:28:45 +0000 (20:28 +0200)]
stringsorter: Implement GtkSortKeys

5 years agosortkeys: Add an equal sort keys
Benjamin Otte [Thu, 16 Jul 2020 10:05:45 +0000 (12:05 +0200)]
sortkeys: Add an equal sort keys

Compares every element as equal.
This is useful when sorters are in an invalid configuration.

5 years agosortlistmodel: Use GtkSortKeys
Benjamin Otte [Tue, 21 Jul 2020 01:40:28 +0000 (03:40 +0200)]
sortlistmodel: Use GtkSortKeys

This massively speeds up sorting with expensive sort functions that it's
the most worthwhile optimization of this whole branch.
It's slower for simple sort functions though.

It's also quite a lot slower when the model doesn't support sort keys
(like GtkCustomSorter), but all the other sorters do support keys.

Of course, this depends on the number of items in the model - the number
of comparisons scales O(N * log N) while the overhead for key handling
scales O(N).
So as the log N part grows, generating keys gets more and more
beneficial.

Benchmarks:

       initial sort of a GFileInfo model with display-name keys
                       items     keys
         8,000 items   715ms     50ms
        64,000 items     ---    554ms

       initial sort of a GFileInfo model with complex keys
                       items     keys
        64,000 items   340ms    295ms
       128,000 items   641ms    605ms

       removing half a GFileInfo model with display-name keys
       (no comparisons, just key freeing overhead of a complex sorter)
                       items     keys
       512,000 items    14ms     21ms
     2,048,000 items    40ms     62ms

       removing half a GFileInfo model with complex keys
       (no comparisons, just key freeing overhead of a complex sorter)
                       items     keys
       512,000 items    90ms    237ms
     2,048,000 items   247ms    601ms

5 years agosorter: Introduce GtkSortKeys
Benjamin Otte [Wed, 15 Jul 2020 18:17:55 +0000 (20:17 +0200)]
sorter: Introduce GtkSortKeys

GtkSortKeys is an immutable struct that can be used to manage "sort
keys" for items.

Sort keys are memory that is created specifically for sorting. Because
sorting involves lots of comparisons, it's a good idea to prepare the
data relevant for sorting in advance and sort on that data.

In measurements with a PropertyExpression on a string sorter, it's about
??? faster

5 years agosortlistmodel: Split the SortItem into 2 arrays
Benjamin Otte [Tue, 21 Jul 2020 01:09:10 +0000 (03:09 +0200)]
sortlistmodel: Split the SortItem into 2 arrays

Instead of one item keeping the item + its position and sorting that
list, keep the items in 1 array and put the positions into a 2nd array.

This is generally slower while sorting, but allows multiple improvements:

1. We can replace items with keys
   This allows avoiding multiple slow lookups when using complex
   comparisons

2. We can keep multiple position arrays
   This allows doing a sorting in the background without actually
   emitting items-changed() until the array is completely sorted.

3. The main list tracks the items in the original model
   So only a single memmove() is necessary there, while the old version
   had to upgrade the position in every item.
Benchmarks:

        sorting a model of simple strings
                          old      new
        256,000 items   256ms    268ms
        512,000 items   569ms    638ms

        sorting a model of file trees, directories first, by size
                          old      new
         64,000 items   350ms    364ms
        128,000 items   667ms    691ms

        removing half the model
                          old      new
        512,000 items    24ms     15ms
      1,024,000 items    49ms     25ms

5 years agosortlistmodel: Add an incremental property
Benjamin Otte [Tue, 21 Jul 2020 00:50:45 +0000 (02:50 +0200)]
sortlistmodel: Add an incremental property

Also refactor a large part of the sortmodel to make this convenient.

A large amount of time has been spent on getting items-changed regions
minimized.

5 years agotestsuite: Add exhaustive sortlistmodel test
Benjamin Otte [Sun, 12 Jul 2020 04:53:06 +0000 (06:53 +0200)]
testsuite: Add exhaustive sortlistmodel test

This is basically a copy/paste from the filterlistmodel test, but
adapted for sorting.

5 years agosortlistmodel: Make the sort callback useful
Benjamin Otte [Mon, 20 Jul 2020 23:40:06 +0000 (01:40 +0200)]
sortlistmodel: Make the sort callback useful

1. Run step() for a while to avoid very short steps
   This way, we batch items-changed() emissions.

2. Track the change region accurately
   This way, we can avoid invalidating the whole list if our step just
   touched a small part of a huge list.
   As this is a merge sort, this is a common occurence when we're buys
   merging chunks: The rest of the model outside those chunks isn't
   changed.

Note that the tracking is accurate: It determines the minimum change
region in the model.

This will be important, because the testsuite is going to test this.

5 years agotimsort: Add change tracking to gtk_tim_sort_step()
Benjamin Otte [Sun, 12 Jul 2020 02:20:19 +0000 (04:20 +0200)]
timsort: Add change tracking to gtk_tim_sort_step()

5 years agotimsort: Add gtk_tim_sort_set_max_merge_size()
Benjamin Otte [Sat, 18 Jul 2020 02:45:46 +0000 (04:45 +0200)]
timsort: Add gtk_tim_sort_set_max_merge_size()

Makes the SOrtListModel responsive when incrementally sorting.

By making it configurable we can avoid losting performance in the
non-incremental case.

5 years agotimsort: Make sure merges don't take too long
Benjamin Otte [Sat, 11 Jul 2020 18:34:16 +0000 (20:34 +0200)]
timsort: Make sure merges don't take too long

Limit the size of the merged areas and thereby chunk larger merges into
smaller ones.

5 years agosortlistmodel: Make sorting incremental
Benjamin Otte [Mon, 20 Jul 2020 23:46:09 +0000 (01:46 +0200)]
sortlistmodel: Make sorting incremental

This is just an experiment so far to see how long it takes to sort.